package com.ldxiwxr.controller.controller;

import com.ldxiwxr.common.common.Result;
import com.ldxiwxr.controller.constant.CorrectnessConstant;
import com.ldxiwxr.system.service.IUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户信息控制类
 * @author SuBanxia
 */
@RestController
@Api(tags = "/UserInfoController")
@RequestMapping("/userInfo")
public class UserInfoController {


    @Resource
    private IUserInfoService userInfoService;

    @ApiOperation("获取用户个人信息")
    @GetMapping("/getUserInfo")
    public Result<?> getUserInfo(){
        return Result.data(userInfoService.getUserInfo());
    }

    @ApiOperation("获取用户可以访问路径")
    @GetMapping("/getAccessPath")
    public Result<?> getAccessPath(){
        return null;
    }

    @ApiOperation("判断用户电话号码是否正确")
    @GetMapping("/checkPhone")
    public Result<?> checkPhone(@RequestParam("phone") String phone){
        if (userInfoService.checkPhone(phone)){
            return Result.data(CorrectnessConstant.CORRECT_CONSTANT);
        }
        return Result.data(CorrectnessConstant.WRONG_CONSTANT);
    }
}
